var mydialog;
var base_name;
$(function(){
	base_name=$("#base_alter_name").html();
});

function cu_exter_add(){
	var ba_mrtline=$("#ba_mrtline").val();
	var ba_remk=$("#ba_remk").val();
	var sort_id=$("#sort_id").val();
	
	if(ba_mrtline==''){
		alert(base_name+'不能為空');
		return;
	}
	
	$.ajax({
		url:'cu_mrtline',
		type:'post',
		data:{operator:'31',type:2,ba_mrtline:ba_mrtline,ba_remk:ba_remk,sort_id:sort_id},
		dataType:'json',
		success:cu_attach_add_status,
		error:function(XMLHttpRequest, textStatus, errorThrown){alert(textStatus);}
	});
}

function cu_attach_add_status(data){
	if(data.status===1){
		location.reload();
	}
}

function cu_exter_alter(id){
	var data=$("#"+id).html();
	art.dialog({
		title:base_name+'-修改',
		content:data,
		lock:true
	});
}

function cu_exter_del(id){
	if(confirm('您確定刪除嗎?')){
		mydialog=art.dialog({title:'請稍候...',lock:true});
		$.ajax({
			url:'cu_mrtline',
			type:'post',
			dataType:'json',
			data:{operator:'31',type:4,id:id},
			success:cu_attach_del_status,
			error:function(XMLHttpRequest, textStatus, errorThrown){alert(textStatus);}
		});
	}
}

function cu_attach_del_status(data){
	if(data.status===1){
		mydialog.content('刪除成功');
		location.reload();
	}
}